<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Gestione gift list</title>
</h:head>
<h:body>
	<h:form id="formGF">
		<p:outputPanel id="output"
			autoUpdate="#{giftlistBean.populateListForAdding()}">


			<h:panelGrid id="displayGfs" columns="2" cellpadding="5">

				<p:dataTable id="dataTableGF" var="glDTO"
					value="#{giftlistBean.glsDTO}" paginator="true" rows="10"
					rowKey="#{glDTO.id}">

					<p:column headerText="id">
						<h:outputText value="#{glDTO.id}" />
					</p:column>

					<p:column headerText="name">
						<h:outputText value="#{glDTO.name}" />
					</p:column>

					<p:column style="width:4%">
						<p:commandButton id="removeButton" icon="ui-icon-trash"
							title="delete gift list" action="#{giftlistBean.removeGF()}">
							<f:setPropertyActionListener value="#{glDTO}"
								target="#{giftlistBean.gfSelezionata}" />
						</p:commandButton>
					</p:column>

					<p:column style="width:4%">
						<p:commandButton id="exploreButton" icon="ui-icon-search"
							title="explore gift list" action="#{giftlistBean.exploreGF()}"
							oncomplete="PF('exploreGF').show()" ajax="true"
							update=":formGF:exploreGF">
							<f:setPropertyActionListener value="#{glDTO}"
								target="#{giftlistBean.gfSelezionata}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>

			</h:panelGrid>

			<p:dialog id="exploreGF" header="Gift list details"
				widgetVar="exploreGF" resizable="false" width="500"
				showEffect="fade" hideEffect="fade">
				<p:outputPanel id="mostraPacchettiProdottiBase">
					<h:outputLabel> Pacchetti associati alla gift list</h:outputLabel>
					<h:panelGrid id="displayPacchetti" columns="2" cellpadding="5">

						<p:dataTable var="pacchettoDTO" value="#{giftlistBean.pacchetti}"
							paginator="true" rows="10" rowKey="#{pacchettoDTO.id}">

							<p:column headerText="id">
								<h:outputText value="#{pacchettoDTO.id}" />
							</p:column>

							<p:column headerText="description">
								<h:outputText value="#{pacchettoDTO.nome}" />
							</p:column>

							<p:column headerText="price">
								<h:outputText value="#{pacchettoDTO.prezzo}" />
							</p:column>

							<p:column style="width:4%">
								<p:commandButton id="cartPButton" icon="ui-icon-cart"
									title="buy" oncomplete="PF('dialog').show()">
									<f:setPropertyActionListener value="#{pacchettoDTO}"
										target="#{giftlistBean.pacchettoAcquistato}" />
								</p:commandButton>
							</p:column>
						</p:dataTable>

					</h:panelGrid>

					<h:outputLabel> ProdottiBase associati alla gift list</h:outputLabel>


					<h:panelGrid id="displayProdottiBase" columns="2" cellpadding="5">

						<p:dataTable var="prodottoBaseDTO"
							value="#{giftlistBean.prodottiBase}" paginator="true" rows="10"
							rowKey="#{prodottobaseDTO.id}">

							<p:column headerText="id">
								<h:outputText value="#{prodottoBaseDTO.id}" />
							</p:column>

							<p:column headerText="price">
								<h:outputText value="#{prodottoBaseDTO.prezzo}" />
							</p:column>

							<p:column style="width:4%">
								<p:commandButton id="cartBpButton" icon="ui-icon-cart"
									title="buy" oncomplete="PF('dialog').show()">
									<f:setPropertyActionListener value="#{glDTO}"
										target="#{giftlistBean.gfSelezionata}" />
								</p:commandButton>
							</p:column>
						</p:dataTable>

					</h:panelGrid>

					<p:dialog id="dlg" header="Buying Details" widgetVar="dialog"
						resizable="false" width="200" showEffect="fade" hideEffect="fade">

						<p:outputLabel>Successfully bought!</p:outputLabel>
					</p:dialog>


				</p:outputPanel>
			</p:dialog>

		</p:outputPanel>



	</h:form>
</h:body>
</html>